You are here: Trading System Programming > Reference > Classes > Account > Account Methods > placeStopOrder

placeStopOrder

The placeStopOrder method places a stop order inline without the need for creating a separate Order object.

Syntax

var placeStopOrder(symbol, quantity, stopPrice, actionType, tifType);

Parameters

symbol

Symbol string for which to place the order.

 

quantity

Floating or numeric order quantity.

 

stopPrice

Stop price floating value.

 

actionType

One of the order action types such as buy or sell.

 

tifType

One of the time-in-force types such as Day or Good-till-Canceled.

Return Value

This method returns true if order was placed successfully, false otherwise.

Example

The following example demonstrates the use of placeStopOrder method.

 

function init()

{

//add "Default Trading Size" parameter

addParameter("Default Trading Size", "This is the default trading size volume", 1000);

}

 

function start()

{

//retrieve short positions for all symbols

var account = getAccount();

 

var placeLongOrder = false;

var stopPrice = 0;

 

//determine whether a long order needs to be placed

..

..

..

 

if(placeLongOrder)

{

var rc = account.placeStopOrder(getSymbol(),

parseFloat(getParameter("Default Trading Size")),

stopPrice,

ACTIONTYPE_BUY,

TIFTYPE_DAY);

}

}

See Also

init(), start(), addParameter(), getParameter()

 


Copyright © 2006-2009 ActiveTick LLC